package com.fr.report.script.core.parser;

import com.fr.base.ColumnRow;
import com.fr.report.script.Calculator;

public class Ambiguity extends Tiny
{
  private String statement;

  Ambiguity(String paramString)
  {
    this.statement = paramString;
  }

  public String getStatement()
  {
    return this.statement;
  }

  public Object eval(Calculator paramCalculator)
    throws UtilEvalError
  {
    if (this.statement == null)
      throw new UtilEvalError("statement in literal is null");
    Object localObject = paramCalculator.resolveVariable(this.statement);
    if (localObject == null)
      throw new UtilEvalError("null field resolved: " + this.statement);
    return localObject;
  }

  public String toString()
  {
    return this.statement;
  }

  public String getExpression(int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean)
  {
    ColumnRow localColumnRow = ColumnRow.valueOf(this.statement.substring(1));
    if ((!(paramBoolean)) && (this.statement.startsWith("$")) && (ColumnRow.validate(localColumnRow)))
    {
      int i = localColumnRow.getColumn();
      if ((paramInt3 != -1) && (localColumnRow.getColumn() >= paramInt3))
        i += paramInt4;
      int j = localColumnRow.getRow();
      if ((paramInt1 != -1) && (localColumnRow.getRow() >= paramInt1))
        j += paramInt2;
      localColumnRow = ColumnRow.valueOf(i, j);
      return "$" + localColumnRow.toString();
    }
    return toString();
  }

  public String[] parserParameter()
  {
    return new String[] { (com.fr.base.StringUtils.isBlank(this.statement)) ? null : this.statement };
  }
}